#include "OutputDisplay.h"
#include<iostream>   //n
#include<sstream>   //n
#include <vector>   //n
using namespace std;   //n

//DisplayText* OutputDisplay::displayText = new DisplayText;
 
//string OutputDisplay::upcomingText = "works fine";

OutputDisplay::OutputDisplay(){
	EventStoragePtr newStoragePtr = &EventStorage::get();
	_eventList = newStoragePtr->getEventVectorPtr();
	upcomingText = NULL_STRING;
	//bottomText = NULL_STRING;
	//displayText->upcomingText = "meet mum at home at 2pm.";
	//displayText->floatingTasksText = "meet friend on Saturday";
	//displayText->labelText = "added: meet mum at home at 2pm";
}

OutputDisplay& OutputDisplay::get() {
	static OutputDisplay newInstance;
	return newInstance;
}

//DisplayText* OutputDisplay::getDisplayPointer(){
//	return displayText;
//}
//void OutputDisplay::readAllText(DisplayText* displayText,EventVector* _eventList){   //n
void OutputDisplay::displayEvents (vector<pos_int> _IDList){ 
	pos_int nIndex = 1;
	for (auto i:_IDList) {
		upcomingText += to_string(nIndex);
		upcomingText += STRING_DOT_SPACE;
        upcomingText += toStringOfEvent((*_eventList)[i]);
		nIndex++;
	 }
}
void OutputDisplay::showAdded(string detailAdded){
    upcomingText += STRING_QUOTATION;
    upcomingText += detailAdded;
    upcomingText += STRING_QUOTATION;
    upcomingText += SPACE_STRING;
    upcomingText += STRING_ADDED;
    upcomingText += NEW_LINE;
}

void OutputDisplay::getToModify(pos_int _IDToModify){
    upcomingText += toStringOfEvent((*_eventList)[_IDToModify]);
}

void OutputDisplay::showModified(pos_int _IDModified){
     upcomingText += STRING_MODIFIED;
     upcomingText += to_string(_IDModified); 
     upcomingText += STRING_DOT_SPACE;
     upcomingText += NEW_LINE;
}

void OutputDisplay::showdeleted(vector<pos_int> _IDDeleted,vector<pos_int> _IDIllegal){
    if((_IDDeleted.size()==0)&&(_IDIllegal.size()==0)){
        upcomingText += STRING_EMPTY_NO_DELETE;
    } else {
        if(_IDDeleted.size()!=0){
            upcomingText += STRING_DELETED;
            for (auto i:_IDDeleted) {
		        upcomingText += to_string(i);
		        upcomingText += SPACE_COMMA_SPACE;
	        }
            upcomingText += NEW_LINE;
        }
        if(_IDIllegal.size()!=0){
            upcomingText += STRING_NOT_DELETED;
            for (auto i:_IDIllegal) {
		        upcomingText += to_string(i);
		        upcomingText += SPACE_COMMA_SPACE;
            }
        }	 
    }
}

//void OutputDisplay::showAdded(DisplayText* displayText,Event* anEvent){//n
	//Event currentEvent = (*_historyEvents).back();
//	string display = anEvent->getDetails() + "added successfully" + "\n";
//	displayText->labelText = display;
//}

//void OutputDisplay::showDeleted(DisplayText* displayText){//n
	//Event currentEvent = (*_historyEvents).back();
	//string display = "deleted successfully" + "\n";
	//displayText->labelText = display;
//}

//void OutputDisplay::showEdited(DisplayText* displayText,vector<Event>* _historyEvents){//n
//	Event currentEvent = (*_historyEvents).back();
//	string display = currentEvent.getDetails() + "edited successfully" + "\n";
//	displayText->labelText = display;
//}

//void OutputDisplay::showUndo(DisplayText* displayText,vector<Event>* _historyEvents){//n
//	Event currentEvent = (*_historyEvents).back();
//	string display = currentEvent.getDetails() + "Undo successfully" + "\n";
//	displayText->labelText = display;
//}

String^ OutputDisplay::getUpcomingText(){
	string temp = upcomingText;
	upcomingText = NULL_STRING;
	return Stdtosys::toSysUpcomingText(temp);
}
//string getbottomText(){
//	string temp = bottomText;
//	bottomText = NULL_STRING;
//	return temp;
//}

//string OutputDisplay::getAllText(){
//	return allText;
//}

//string OutputDisplay::getTodayText(){
//	return todayText;
//}

//string OutputDisplay::getWeekText(){
//	return weekText;
//}

//string OutputDisplay::getFloatingTasksText(){
//	return floatingTasksText;
//}

//string OutputDisplay::getPastOperationsText(){
//	return pastEntriesText;
//}

//string OutputDisplay::getLabelText(){
//	return labelText;
//}

/////string OutputDisplay::showHelp(){//="expected input: help command\n"+"like 'help add' for add format, supporting commands: add, delete, display, edit, undo\n";
/////return helpText;
/////}
/////string OutputDisplay::showHelpAdd(){//="expected input: add content\n"+"add 'generatedindex content' to issues.\n";
/////return helpAdd;
/////}
/////string OutputDisplay::showHelpDelete(){//="expected input: delete index/indices\n"+"display all the 'generatedindex content'\n";
/////return helpDelete;
/////}
/////string OutputDisplay::showHelpDisplay(){//="expected input: display\n"+"add 'generatedindex content' to issues.\n";
/////return helpDisplay;
/////}
/////string OutputDisplay::showHelpModify(){//="expected input: edit indextobeedit new content\n"+"replace the old content at the index with new content\n";
/////return helpModify;
/////}
/////string OutputDisplay::showHelpUndo(){//="expected input: undo\n"+"cancel last command\n";
/////return helpUndo;
/////}
/////string OutputDisplay::showAdded(){//="added successfully\n";
/////return Added;
/////}
/////string OutputDisplay::showDeleted(){//="deleted successfully\n";
/////return Deleted;
/////}
/////string OutputDisplay::showDisplayed(){//="displayed successfully\n";
/////return Displayed;
/////}
/////string OutputDisplay::showModified(){//="added successfully\n";
/////return Modified;
/////}
/////string OutputDisplay::showUndid(){//="undo successfully\n";	
/////return Undid;
/////}

//String^ OutputDisplay::convertToSystemString(string toBeConverted){
//	String^ systemString = gcnew String(toBeConverted.c_str());
//	return systemString;
//}

